﻿<Window x:Class="TfsStorageExplorer.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="TFS Storage Explorer"
        WindowStartupLocation="CenterScreen"
        Icon="App.ico"
        Height="600" Width="800">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <GroupBox Header="Options" Grid.Row="0" Margin="5" Padding="5">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <TextBlock Grid.Column="0" Grid.Row="0" Text="Team Project Collection URL" VerticalAlignment="Center" />
                <ComboBox Grid.Column="1" Grid.Row="0" ItemsSource="{Binding Path=AvailableTeamProjectCollectionUrls}" Text="{Binding Path=TeamProjectCollectionUrl, UpdateSourceTrigger=PropertyChanged}" IsEditable="True" Margin="5,0,0,0" />
                <TextBlock Grid.Column="0" Grid.Row="1" Text="Options" VerticalAlignment="Center" Margin="0,5,0,0" />
                <WrapPanel Grid.Column="1" Grid.Row="1" Margin="3,5,0,0">
                    <CheckBox Content="Ignore Build Log Containers" IsChecked="{Binding Path=IgnoreBuildLogs}" VerticalAlignment="Center" ToolTip="Skip containers that contain Team Build log files" />
                </WrapPanel>
                <Button Grid.Column="2" Grid.Row="0" Grid.RowSpan="2" Command="{Binding Path=RefreshContainersCommand}" Margin="5,0,0,0" Padding="10,0,10,0" ToolTip="Load the storage containers available in the specified Team Project Collection">
                    <Image Source="Resources/Refresh.png" Stretch="None" />
                </Button>
            </Grid>
        </GroupBox>
        <GroupBox Header="Storage" Grid.Row="1" Margin="5,0,5,5" Padding="5">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="200" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <TreeView Grid.Column="0" ItemsSource="{Binding Path=Nodes}" x:Name="foldersTreeView">
                    <TreeView.ItemContainerStyle>
                        <Style TargetType="{x:Type TreeViewItem}">
                            <Setter Property="IsExpanded" Value="{Binding Path=IsExpanded, Mode=TwoWay}" />
                        </Style>
                    </TreeView.ItemContainerStyle>
                    <TreeView.ItemTemplate>
                        <HierarchicalDataTemplate ItemsSource="{Binding Path=NonFileChildrenLazy}">
                            <StackPanel Orientation="Horizontal">
                                <Image Source="{Binding Path=Icon}" Width="16" Height="16" />
                                <TextBlock Text="{Binding Path=Name}" ToolTip="{Binding Path=Description}" Margin="3,0,0,0" />
                            </StackPanel>
                        </HierarchicalDataTemplate>
                    </TreeView.ItemTemplate>
                </TreeView>
                <GridSplitter Grid.Column="1" Width="3" Margin="3,0,3,0" HorizontalAlignment="Stretch" ResizeDirection="Columns" />
                <Grid Grid.Column="2">
                    <Grid.Style>
                        <Style TargetType="Grid">
                            <Setter Property="Visibility" Value="Collapsed" />
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding ElementName=foldersTreeView, Path=SelectedItem.IsLoading}" Value="True">
                                    <Setter Property="Visibility" Value="Visible" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Grid.Style>
                    <TextBlock Text="Loading..." FontSize="24" HorizontalAlignment="Center" />
                </Grid>
                <Grid Grid.Column="2">
                    <Grid.Style>
                        <Style TargetType="Grid">
                            <Setter Property="Visibility" Value="Collapsed" />
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding ElementName=foldersTreeView, Path=SelectedItem.IsLoading}" Value="False">
                                    <Setter Property="Visibility" Value="Visible" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Grid.Style>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <DataGrid Grid.Row="0" ItemsSource="{Binding ElementName=foldersTreeView, Path=SelectedItem.Children}" IsReadOnly="True" AutoGenerateColumns="False" x:Name="childrenDataGrid" SelectionChanged="childrenDataGrid_SelectionChanged">
                        <DataGrid.Columns>
                            <DataGridTemplateColumn>
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Image Source="{Binding Path=Icon}" Width="16" Height="16" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTextColumn Header="Name" Binding="{Binding Path=Name}" Width="*" />
                            <DataGridTextColumn Header="Date Created" Binding="{Binding Path=DateCreated}" />
                            <DataGridTextColumn Header="Date Last Modified" Binding="{Binding Path=DateLastModified}" />
                            <DataGridTextColumn Header="Size" Binding="{Binding Path=Size}" />
                        </DataGrid.Columns>
                    </DataGrid>
                    <Grid Grid.Row="1" Margin="0,5,0,0">
                        <Button Content="Download Selected Files" Command="{Binding Path=DownloadSelectedFilesCommand}" Padding="5" />
                    </Grid>
                </Grid>
            </Grid>
        </GroupBox>
        <StatusBar Grid.Row="2" Margin="0,0,0,0">
            <StatusBarItem>
                <TextBlock Text="{Binding Path=StatusText}" Margin="5,0,0,0" />
            </StatusBarItem>
        </StatusBar>
    </Grid>
</Window>